<script setup lang="ts">
import { ref } from "vue";
import { formRules } from "../utils/rule";
import { FormProps } from "../utils/types";
import { FileUpload } from "@/components/common/FileUpload/index";

const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    id: "",
    brandName: "",
    logo: undefined,
    fileList: ""
  })
});

const ruleFormRef = ref();
const newFormInline = ref(props.formInline);

function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });
</script>

<template>
  <el-form
    ref="ruleFormRef"
    :model="newFormInline"
    :rules="formRules"
    label-width="100px"
  >
    <el-row>
      <el-col :span="16" class="m-auto">
        <el-form-item label="品牌名称" prop="brandName">
          <el-input
            v-model="newFormInline.brandName"
            clearable
            placeholder="请输入品牌名称"
          />
        </el-form-item>
      </el-col>
    </el-row>

    <el-row>
      <el-col :span="16" class="m-auto">
        <el-form-item label="品牌LOGO" prop="logo">
          <FileUpload
            ref="fileUploadRef"
            v-model="newFormInline.logo"
            :fileType="['jpg', 'png']"
            :limit="1"
            :maxSize="2"
          />
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>

<style scoped lang="scss">
.asdxsad {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 150px;
  height: 150px;
  border: 1px dashed var(--el-border-color);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--el-transition-duration-fast);
  text-align: center;
}
.avatar {
  width: 150px;
  height: 150px;
}
</style>
